package com.after.saas.common.utils;


import com.after.saas.common.constants.CommonCodeEnum;
import com.after.saas.common.constants.IResultEnum;
import com.after.saas.common.constants.Result;

/**
 * @Classname ResponseUtil
 * @Description TODO
 * @Date 2021/4/27 17:04
 * @Created by hjchen
 */
public class ResponseUtil {

    public static final int SUCCESS = 200;
    public static final int STATUS = 301;
    public static final int ERROR = 500;
    public static final int FORBID = 401;

    /**
     * 成功
     *
     * @return
     */
    public static <T> Result<T> SUCCESS() {
        return new Result<T>(CommonCodeEnum.SUCCESS);
    }

    public static <T> Result<T> SUCCESS(String message) {
        return new Result<T>(SUCCESS, message);
    }

    public static <T> Result<T> SUCCESS(T data) {
        return new Result<T>(CommonCodeEnum.SUCCESS, data);
    }

    public static <T> Result<T> SUCCESS(IResultEnum resultEnum) {
        return new Result<T>(resultEnum);
    }

    public static <T> Result<T> SUCCESS(String message, T data) {
        return new Result<T>(SUCCESS, message, data);
    }


    public static <T> Result<T> SUCCESS(IResultEnum message, T data) {
        return new Result<T>(message.value(), message.message(), data);
    }

    /**
     * 失败
     *
     * @return
     */
    public static <T> Result<T> FAILURE() {
        return new Result<T>(ERROR);
    }

    public static <T> Result<T> FAILURE(int code, String message) {
        return new Result<T>(code, message);
    }

    public static <T> Result<T> FAILURE(String message) {
        return new Result<T>(ERROR, message);
    }

    public static <T> Result<T> FAILURE(String message, T data) {
        return new Result<T>(ERROR, message, data);
    }

    public static <T> Result<T> FAILURE(IResultEnum message) {
        return new Result<T>(message);
    }

    public static <T> Result<T> FAILURE(IResultEnum message, T data) {
        return new Result<T>(message.value(), message.message(), data);
    }

    public static <T> Result<T> FORBID(String message) {
        return new Result<T>(FORBID, message);
    }

    /**
     * 消息提示
     */
    public static <T> Result<T> MESSAGE(String message) {
        return new Result<T>(STATUS, message);
    }

    public static <T> Result<T> MESSAGE(String message, T data) {
        return new Result<T>(STATUS, message, data);
    }

}